#include<bits/stdc++.h>
using namespace std;
struct abc{
	int d,v0,a;
}car[100010];
int main()
{
	int t,n,m,l,v,p[100010],c=0;
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin >>t;
	while(t!=0)
	{
		c=0;
		cin >>n>>m>>l>>v;
		for(int i=1;i<=n;i++) cin >>car[i].d>>car[i].v0>>car[i].a;
		for(int i=1;i<=m;i++) cin >>p[i];
		if(car[1].a==0)
		{
			for(int i=1;i<=n;i++)
			{
				if(car[i].v0>v&&p[m]>=car[i].d) c++;
			}
			if(c==0) cout <<c<<" "<<m<<endl;
			else cout <<c<<" "<<m-1<<endl;
		}
		else if(car[1].a>0)
		{
			for(int i=1;i<=n;i++)
			{
				int s=(v*v-car[i].v0*car[i].v0)/(2*car[i].a)+car[i].d;
				if(p[m]>=s) c++;
			}	
			if(c==0) cout <<c<<" "<<m<<endl;
			else cout <<c<<" "<<m-1<<endl;
		}
		t--;
	}
	return 0;
}
